/*
 * @File: 
 * @Author: Cc
 * @Date: 2022-04-02 16:33:15
 * @LastEditors: Cc
 * @LastEditTime: 2022-04-02 16:39:40
 * @FilePath: \test-unicorn\src\pages\webSoket\index.tsx
 */
import React, { useState ,useEffect ,useCallback } from 'react';
function useWinSize() {
  const [size, setSize] = useState({
    width: document.documentElement.clientWidth,
    height: document.documentElement.clientHeight
  });
  const onResize = useCallback(() => {
    setSize({
      width: document.documentElement.clientWidth,
      height: document.documentElement.clientHeight
    });
  }, []);
  useEffect(() => {
    window.addEventListener('resize', onResize);
    return () => {
      window.removeEventListener('resize', onResize);
    };
  }, []);
  return size;
};
export default useWinSize;